package cn.itrip.auth.controller;

import cn.itrip.auth.service.UserService;
import cn.itrip.beans.dtos.Dto;
import cn.itrip.beans.pojo.User ;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.util.concurrent.TimeUnit;

/**
 * 文档注释 生成 帮助文件
 * RestController  == Controller  +  ResponseBody
 *          返回的是JSON
 */
@RestController  //
@RequestMapping("/api/")
public class UserControllre {
    @Resource
    private UserService userService;
    //判断邮箱/手机 是否已经存在
    @GetMapping("ckusr")
    public Dto isExists(String name){
        return  userService.isExists(name);
    }
    //邮箱注册功能
    @PostMapping("doregister")
    public Dto regeditByEmail(@RequestBody User user) throws MessagingException {
        return  userService.regedit(user);
    }
    //邮箱/手机激活
    @PutMapping("activate")
    public Dto activeUser(String user,String code){
        return userService.activeUser(user,code);
    }
    //手机注册
    @PostMapping("registerbyphone")
    public Dto registerbyphone(@RequestBody User user) throws MessagingException {
        return  userService.regeditByphone(user);
    }

}
